package demo.begin;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author DGW-PC
 * @data   2018年8月28日下午4:01:52
 * <a href="https://www.cnblogs.com/dgwblog/">我的博客</a>
 */
@Controller
@RequestMapping("/springRest")
public class MvcRest {
	
	private static Logger logger=Logger.getLogger(MvcRest.class.getName());
	
	private final String SUCCESS="success";
	
	/**
	 *  JSPs only permit GET POST or HEAD.。 异常
	 *  第一：taocat换到7.0以及以下版本
		第二：请求先转给一个Controller,再返回jsp页面
		第三种：在你的success页面头部文件将
		<%@ page language="java" contentType="text/html; charset=UTF-8"
		pageEncoding="UTF-8" isErrorPage="true"%>
		多加一句话：isErrorPage设置为true，默认为false
	 * 
	 * @param id
	 * @return String
	 */
	
	@RequestMapping(value="/put/{id}",method=RequestMethod.PUT)
	public String testPut(@PathVariable("id") Integer id) {
		logger.log(Level.INFO,"PUT 方法");
		return SUCCESS;
	}

	@RequestMapping(value="/delete/{id}",method=RequestMethod.DELETE)
	public String testDelete(@PathVariable("id") Integer id) {
		logger.log(Level.INFO,"DELETE 方法");
		return SUCCESS;
	}

	@RequestMapping(value="/post/{id}",method=RequestMethod.POST)
	public String testPost(@PathVariable("id") Integer id) {
		logger.log(Level.INFO,"POST 方法");
		return SUCCESS;
	}
	
	@RequestMapping(value="/get/{id}",method=RequestMethod.GET)
	public String testGet(@PathVariable("id") Integer id) {
		logger.log(Level.INFO,"GET 方法");
		return SUCCESS;
	}

}
